package com.xiaotou.db.dao;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import com.xiaotou.db.pojo.AppUser;

/**
 * Data access object (DAO) for domain model class User.
 * 
 * @see com.XiaotouUserUser.db.pojo.User
 * @author MyEclipse - Hibernate Tools
 */
@Repository("appUserDao")
public class AppUserDAO extends HibernateDaoSupport {

	private static final Log log = LogFactory.getLog(AppUserDAO.class);

	public void save(AppUser user) {

		log.debug("saving User instance");
		try {
			getHibernateTemplate().save(user);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void update(AppUser user) {

		log.debug("saving User instance");
		try {
			getHibernateTemplate().update(user);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(AppUser user) {
		log.debug("deleting User instance");
		try {
			getHibernateTemplate().delete(user);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public AppUser findById(Long id) {
		log.debug("getting User instance with id: " + id);
		try {
			AppUser instance = (AppUser) getHibernateTemplate().get(
					"com.xiaotou.db.pojo.XiaotouUser", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
}